Learning Objectives

After completing this lesson, you’ll be able to:

Resources

Exercise

Your team is responsible for maintaining parks and other grassed areas and needs to know the area and facilities of each park to plan their budget for the upcoming year.

In this part of the project, we’ll filter out dog parks from the source data, as these have a different scale of maintenance costs. We'll then inspect our data to ensure the parks were filtered correctly.

1) Start FME Workbench

Start FME Workbench (2024.0 or later) and open the starting workspace (C:\FMEData\Workspaces\TransformAttributes\exercise-use-conditional-filtering.fmw). This workspace reads in parks MapInfo TAB data, slightly edits the schema using the AttributeManager, and then writes it back to MapInfo TAB.

Starting workspace

2) Add a Tester Transformer

Now, we should remove dog parks from the data because these have their own set of costs.

We can do this with a Tester transformer. Click on the connection from the AttributeManager output port to the ParksMaintenanceData feature type on the Writer.

Start typing the word Tester. When you spot the Tester transformer, double-click on it to add one to the workspace. After tidying up the layout of the canvas, the workspace will now look like this:

Adding a Tester

Notice that the Passed output port is the one connected by default.

3) Set the Tester Parameters

Inspect the parameters for the Tester transformer. Click in the Left Value field, and from there, click the down arrow and choose Attribute Value > DogPark:

Selecting DogPark as the Left Value

For the Right Value, click into the field and type the value N. The operator field should be filled in automatically as the equals sign (=), which is what we want in this case.

Completed test clause

Click OK to accept the values and close the dialog.

Note

The test is for DogParks = N because we want to keep those features, and it is the Passed port that is connected. If the test were DogParks = Y, then the Failed port would be the one to connect.

4) Add Logger

Perhaps you don't only want to filter the failed features out, but to also add them to the log file to keep a record. To do this, you can add a Logger transformer.

Add a Logger transformer to the canvas and connect it to the Tester's Failed port. Rename the transformer to Tester_Failed to reflect what is being logged.

Adding a Logger

Now FME will log information about each failed feature.

5) Run Workspace

Save and run the workspace. 

To confirm it ran correctly, you should have 73 features from the Tester's Passed output port and seven from the Tester's Failed output port. You can inspect the failed features by clicking the feature cache icon to confirm these are, in fact, the dog parks:

Inspecting the Tester:Failed port to confirm that only dog parks are selected

You should also see a record of each failed feature in the log:

Tester_Failed: Feature is:
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Feature Type: `Tester_Failed_LOGGED'
Attribute(string: windows-1252)    : `DogPark' has value `Y'
Attribute(string: windows-1252)    : `Neighborhood' has value `Strathcona'
Attribute(32 bit integer)          : `ParkId' has value `29'
Attribute(string: windows-1252)    : `ParkName' has value `Strathcona Park'
etc...

Challenge

Want to try some optional added challenges?

  1. Use the AttributeRangeFilter to filter your features into several groups based on the value of VisitorCount. You can choose the cut-off points.
  2. Use the TestFilter to create separate streams for dog parks, large non-dog parks, and small non-dog parks.